﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Client;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace MangoMes.Write.API.Applications.Clientss
{
    public class ClientTypeAddHandler : IRequestHandler<ClientTypeAddCommand, ResultsDTO<ClientType>>
    {
        private readonly IBateRepository<ClientType> clienttypes;
        public ClientTypeAddHandler(IBateRepository<ClientType> clienttypes)
        {
            this.clienttypes = clienttypes; 
        }
        public async Task<ResultsDTO<ClientType>> Handle(ClientTypeAddCommand request, CancellationToken cancellationToken)
        {
            DapperHelper dapperHelper = new DapperHelper();
            ClientType clientType=new ClientType();
           ResultsDTO<ClientType> dto=new ResultsDTO<ClientType>();
            string conn = dapperHelper.MangoMesWrite;
            string sql = "select * from clienttype";
            dto.Data = clienttypes.GetAll(sql, clientType, conn).ToList();
            return dto;
        }
    }
}
